1 Transects

Plant Flowers Date lon lat ele Year
Glossoloma oblongicalyx 4 2015-10-19 -78.59093 0.130838 2270 1445238000y 0m 0d 0H 0M 0S
Gasteranthus quitensis 2 2016-10-17 -78.59770 0.120070 1940 1476687600y 0m 0d 0H 0M 0S
Kohleria affinis 1 2016-12-13 -78.59534 0.126746 2110 1481616000y 0m 0d 0H 0M 0S
Columnea ciliata 3 2014-02-27 -78.59934 0.116682 1960 1393488000y 0m 0d 0H 0M 0S
Columnea medicinalis 1 2014-04-23 -78.59372 0.128700 2130 1398236400y 0m 0d 0H 0M 0S
Drymonia teuscheri 3 2016-07-28 -78.59245 0.129393 2200 1469689200y 0m 0d 0H 0M 0S

2 Interactions

2.1 Species elevation ranges

2.2 Flowering Data Matrix

3 Are flowering patterns non-random with respect hummingbird overlap and elevation?

Let’s start with a traditional randomization test to get everyone comfortable with the essential result. For each random draw, calculate the mean niche overlap in hummingbird usage. Species can only bloom at site which they occur. Mantains plant abundance.

3.1 Prepare data for JAGS

4 Species Identity

Equal probability of flowering at anytime.

## sink("model/threshold_baseline.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
## 
##     #Observation of a flowering plant
##     Y[x] ~ dbern(p[x])
##     logit(p[x]) <- alpha[Plant[x]] 
##     
##     #Residuals
##     discrepancy[x] <- abs(Y[x] - p[x])
##     
##     #Assess Model Fit
##     Ynew[x] ~ dbern(p[x])
##     discrepancy.new[x]<-abs(Ynew[x] - p[x])
##     }
##     
##     
##     #Sum discrepancy
##     fit<-sum(discrepancy)/Nobs
##     fitnew<-sum(discrepancy.new)/Nobs
##     
##     #Prediction
##     
##     for(x in 1:Npreds){
##     #predict value
##     
##     #Observation - probability of flowering
##     prediction[x] ~ dbern(p_new[x])
##     logit(p_new[x])<-alpha[PredPlant[x]]
##     
##     #predictive error
##     pred_error[x] <- abs(Ypred[x] - p_new[x])
##     }
##     
##     
##     #Predictive Error
##     fitpred<-sum(pred_error)/Npreds
##     
##     #Priors
##     
##     #Species level priors
##     
##     for (j in 1:Plants){
##     
##     #Intercept flowering probability
##     alpha[j] ~ dnorm(0,0.386)
##     
##     } 
## 
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 3585
##    Unobserved stochastic nodes: 4275
##    Total graph size: 20054
## 
## Initializing model

5 Get Chains

5.0.1 Evaluate convergence

5.0.2 Posterior estimates

6 Species Identity + Site

Equal probability of flowering per elevation

## sink("model/threshold_baseline_site.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
##     
##     #Observation of a flowering plant
##     Y[x] ~ dbern(p[x])
##     logit(p[x]) <- alpha[Plant[x],Site[x]] 
##     
##     #Residuals
##     discrepancy[x] <- abs(Y[x] - p[x])
##     
##     #Assess Model Fit
##     Ynew[x] ~ dbern(p[x])
##     discrepancy.new[x]<-abs(Ynew[x] - p[x])
##     }
##     
##     
##     #Sum discrepancy
##     fit<-sum(discrepancy)/Nobs
##     fitnew<-sum(discrepancy.new)/Nobs
##     
##     #Prediction
##     
##     for(x in 1:Npreds){
##     #Observation - probability of flowering
##     prediction[x] ~ dbern(p_new[x])
##     logit(p_new[x])<-alpha[NewPlant[x],NewSite[x]]
##     
##     #predictive error
##     pred_error[x] <- abs(Ypred[x] - p_new[x])
##     }
##     
##     
##     #Predictive Error
##     fitpred<-sum(pred_error)/Npreds
##     
##     #Priors
##     
##     #Species level priors
##     for (i in 1:Plants){
##     for(j in 1:Sites){
##     
##     #Intercept flowering probability
##     alpha[i,j] ~ dnorm(0,0.386)
##     
##     } 
##     }
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 3585
##    Unobserved stochastic nodes: 4350
##    Total graph size: 24695
## 
## Initializing model

7 Get Chains

7.0.1 Evaluate convergence

7.0.2 Posterior estimates

8 Species Identity + Site + Month

Equal probability of flowering per elevation

## sink("model/threshold_baseline_site_month.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
##     
##     #Observation of a flowering plant
##     Y[x] ~ dbern(p[x])
##     logit(p[x]) <- alpha[Plant[x],Site[x],Month[x]] 
##     
##     #Residuals
##     discrepancy[x] <- abs(Y[x] - p[x])
##     
##     #Assess Model Fit
##     Ynew[x] ~ dbern(p[x])
##     discrepancy.new[x]<-abs(Ynew[x] - p[x])
##     }
##     
##     
##     #Sum discrepancy
##     fit<-sum(discrepancy)/Nobs
##     fitnew<-sum(discrepancy.new)/Nobs
##     
##     #Prediction
##     
##     for(x in 1:Npreds){
##     #Observation - probability of flowering
##     prediction[x] ~ dbern(p_new[x])
##     logit(p_new[x])<-alpha[NewPlant[x],NewSite[x],NewMonth[x]]
##     
##     #predictive error
##     pred_error[x] <- abs(Ypred[x] - p_new[x])
##     }
##     
##     
##     #Predictive Error
##     fitpred<-sum(pred_error)/Npreds
##     
##     #Priors
##     
##     #Species level priors
##     for (i in 1:Plants){
##       sigma_month[i] ~ dgamma(0.0001,0.0001)
##     for(j in 1:Sites){
##       alpha_site[i,j] ~ dnorm(0,0.386)
##     for(k in 1:Months){
##     #Intercept flowering probability
##       alpha[i,j,k] ~ dnorm(alpha_site[i,j],sigma_month[i])
##     }
##     } 
##     }
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 3585
##    Unobserved stochastic nodes: 5445
##    Total graph size: 33478
## 
## Initializing model

9 Get Chains

9.0.1 Evaluate convergence

9.0.2 Posterior estimates

10 Predictive Models of Co-Flowering

10.1 Visitor Attraction

11 Get Chains

11.1 Attraction

## sink("model/threshold_attraction.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
##     
##     #Observation of a flowering plant
##     Y[x] ~ dbern(p[x])
##     logit(p[x]) <-  alpha[Plant[x],Site[x]] + e[Plant[x],Site[x],Month[x]]
##     
##     #Residuals
##     discrepancy[x] <- abs(Y[x] - p[x])
##     
##     #Assess Model Fit
##     Ynew[x] ~ dbern(p[x])
##     discrepancy.new[x]<-abs(Ynew[x] - p[x])
##     }
##     
##     #Sum discrepancy
##     fit<-sum(discrepancy)/Nobs
##     fitnew<-sum(discrepancy.new)/Nobs
##     
##     #Prediction
##     
##     for(x in 1:Npreds){
##     #predict value
##     
##     #Observation - probability of flowering
##     prediction[x] ~ dbern(p_new[x])
##     logit(p_new[x])<- alpha[NewPlant[x],NewSite[x]] + e[NewPlant[x],NewSite[x],NewMonth[x]]
##     
##     #predictive error
##     pred_error[x] <- abs(Ypred[x] - p_new[x])
##     }
##     
##     #Predictive Error
##     fitpred<-sum(pred_error)/Npreds
##     
##     #########################
##     #autocorrelation in error
##     #########################
##     
##     #For each of observation
##     for(y in 1:Sites){
##     for(x in 1:Months){
##     e[1:Plants,y,x] ~ dmnorm(zeros,tauC[,])
##     }
##     }
## 
##     ##covariance among similiar species
##     for(i in 1:Plants){
##     for(j in 1:Plants){
##     C[i,j] = exp(-lambda_cov * D[i,j])
##     }
##     }
##     
##     ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
##     vCov = omega*C[,] + (1-omega) * I
##     tauC=inverse(vCov*gamma)
##     
##     #Priors
##     
##     #Species level priors
##     
##     for (j in 1:Plants){
##       for(k in 1:Sites){
##       #Intercept flowering probability
##       alpha[j,k] ~ dnorm(0,0.386)
##     } }
## 
##     #Autocorrelation priors
##     gamma  ~ dunif(0,5)
##     
##     #Strength of covariance decay
##     lambda_cov ~ dunif(0,5)
##     omega = 1
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 3585
##    Unobserved stochastic nodes: 4424
##    Total graph size: 35305
## 
## Initializing model

11.1.1 Evaluate convergence

11.1.2 Posterior estimates

11.2 Effect of interaction attraction

11.3 Repulsion

## sink("model/threshold_repulsion.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
##     
##     #Observation of a flowering plant
##     Y[x] ~ dbern(p[x])
##     logit(p[x]) <-  alpha[Plant[x],Site[x]] + e[Plant[x],Site[x],Month[x]]
##     
##     #Residuals
##     discrepancy[x] <- abs(Y[x] - p[x])
##     
##     #Assess Model Fit
##     Ynew[x] ~ dbern(p[x])
##     discrepancy.new[x]<-abs(Ynew[x] - p[x])
##     }
##     
##     
##     #Sum discrepancy
##     fit<-sum(discrepancy)/Nobs
##     fitnew<-sum(discrepancy.new)/Nobs
##     
##     #Prediction
##     
##     for(x in 1:Npreds){
##     #predict value
##     
##     #Observation - probability of flowering
##     prediction[x] ~ dbern(p_new[x])
##     logit(p_new[x])<-  alpha[NewPlant[x],NewSite[x]] + e[NewPlant[x],NewSite[x],NewMonth[x]]
##     
##     #predictive error
##     pred_error[x] <- abs(Ypred[x] - p_new[x])
##     }
##     
##     #Predictive Error
##     fitpred<-sum(pred_error)/Npreds
##     
##     #########################
##     #autocorrelation in error
##     #########################
##     
##     #For each of observation
##     for(x in 1:Months){
##     for(y in 1:Sites){
##     e[1:Plants,y,x] ~ dmnorm(zeros,tauC[,])
##     }
##     }
##     ##covariance among similiar species
##     for(i in 1:Plants){
##     for(j in 1:Plants){
##     C[i,j] = exp(-lambda_cov * D[i,j])
##     }
##     }
##     
##     ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
##     vCov = omega*C[,] + (1-omega) * I
##     tauC=vCov*gamma
##     
##     #Priors
##     
##     #Species level priors
##     
##     for (j in 1:Plants){
##       for(k in 1:Sites){
##       #Intercept flowering probability
##       alpha[j,k] ~ dnorm(0,0.386)
##       }
##     } 
## 
##     #Autocorrelation priors
##     gamma ~ dunif(0,5)
##     
##     #Strength of covariance decay
##     lambda_cov ~ dunif(0,5)
##     omega  = 1
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 3585
##    Unobserved stochastic nodes: 4424
##    Total graph size: 35304
## 
## Initializing model

12 Get Chains

12.0.1 Evaluate convergence

12.0.2 Posterior estimates

12.1 Effect of interaction repulsion

13 Model Comparison

13.0.1 E: The effect of autocorrelation

14 P(Flowering)

# One example

Glossoloma purpureum

14.1 Alpha: Species specific flowering rate

14.2 Omega: The magnitude of the effect of autocorrelation on mean flowering occurrence

14.3 Gamma: The variance of the effect of autocorrelation on mean flowering occurrence

14.4 Lambda: The decay in autocorrelation effect

14.5 Decay in autocorrelation effect

15 Model Fit

15.1 Bayesian pvalue

## # A tibble: 5 x 2
##   Model                      p
##   <chr>                  <dbl>
## 1 baseline               0.542
## 2 baseline_site          1    
## 3 baseline_site_month    1    
## 4 interaction_attraction 1    
## 5 interaction_repulsion  1

Without baseline

## # A tibble: 4 x 2
##   Model                      p
##   <chr>                  <dbl>
## 1 baseline_site              1
## 2 baseline_site_month        1
## 3 interaction_attraction     1
## 4 interaction_repulsion      1

15.2 Model Fit

Model mean lower upper
baseline_site 0.2015586 0.1964144 0.2068303
baseline_site_month 0.1853191 0.1756552 0.1953314
interaction_repulsion 0.1826840 0.1757859 0.1894327
interaction_attraction 0.1798205 0.1725367 0.1874824

15.2.1 Without baseline

15.3 By Species

15.3.1 Without baseline

15.3.2 Zoom in

16 Prediction

16.1 Example from Glossoloma oblongicalyx

16.1.1 Tables

Model mean lower upper
baseline 0.2179920 0.2111130 0.2255539
baseline_site 0.2004830 0.1938548 0.2074097
baseline_site_month 0.1940599 0.1858530 0.2025038
interaction_attraction 0.1930091 0.1851200 0.2007233
interaction_repulsion 0.1926848 0.1848993 0.2004418

17 Flowering correlations in predictions

18 Example

Columnea medicinialis v Columnea strigosa which have strong overlap in visitors

Dint["Columnea medicinalis","Columnea strigosa"]
## [1] 0.2096899

Logit E

inv.logit E

## # A tibble: 2 x 4
## # Groups:   Model [2]
##   Model                  Var1                Var2             Correlation_E
##   <chr>                  <fct>               <fct>                    <dbl>
## 1 interaction_attraction Columnea medicinal… Columnea strigo…         0.862
## 2 interaction_repulsion  Columnea medicinal… Columnea strigo…        -0.612
## # A tibble: 5 x 4
## # Groups:   Model [5]
##   Model                  Var1                Var2             Correlation_P
##   <chr>                  <fct>               <fct>                    <dbl>
## 1 baseline               Columnea medicinal… Columnea strigo…        NA    
## 2 baseline_site          Columnea medicinal… Columnea strigo…         0.233
## 3 baseline_site_month    Columnea medicinal… Columnea strigo…         0.248
## 4 interaction_attraction Columnea medicinal… Columnea strigo…         0.244
## 5 interaction_repulsion  Columnea medicinal… Columnea strigo…         0.218
## # A tibble: 5 x 4
## # Groups:   Model [5]
##   Model                 Var1               Var2            Correlation_Ynew
##   <chr>                 <fct>              <fct>                      <dbl>
## 1 baseline              Columnea medicina… Columnea strig…           NA    
## 2 baseline_site         Columnea medicina… Columnea strig…            0.233
## 3 baseline_site_month   Columnea medicina… Columnea strig…            0.159
## 4 interaction_attracti… Columnea medicina… Columnea strig…            0.173
## 5 interaction_repulsion Columnea medicina… Columnea strig…            0.193

19 Figures for the paper

20 Figure 1

Flowering patterns

21 Example Flowering patterns

22 Figure 4

Model Fit and Prediction Fit

23 Predictions from the baseline models

Comparison of the attraction and repulsion

23.1 For a given plant

Overlay

Predictions from the best model

Supplamental figures